(function(s){typeof define=="function"&&define.amd?define(s):s()})(function(){"use strict";const s=["discordsays.com","discordsez.com"],r="/.proxy";function f(){return new URLSearchParams(window.location.search).get("frame_id")!=null}function a(e,o=r){var l;const i=((l=globalThis["@robojs/patch"])==null?void 0:l.mappings)??[],n=typeof e=="string"?window.location.origin:void 0,t=new URL(e instanceof Request?e.url:String(e),n);return s.some(c=>t.hostname.endsWith(c))&&!i.find(c=>t.pathname.startsWith(c))&&!t.pathname.startsWith(o)&&(t.pathname=o+t.pathname),e instanceof Request?new Request(t,{method:e.method,headers:e.headers,body:e.bodyUsed?null:e.body,mode:e.mode,credentials:e.credentials,duplex:e.body instanceof ReadableStream?"half":void 0,cache:e.cache,redirect:e.redirect,referrer:e.referrer,referrerPolicy:e.referrerPolicy,integrity:e.integrity,keepalive:e.keepalive,signal:e.signal}):t}function m(){const e=globalThis.fetch;globalThis.fetch=function(o,i){const{prefix:n=r,...t}=i??{},h=a(o,n);return e(h,t)}}function g(){WebSocket=new Proxy(window.WebSocket,{construct(o,i){const n=a(i[0]),t=i[1];return new o(n,t)}})}const d="node_modules/@robojs/patch/.robo/public/discord-proxy-patch.umd.js",p="assets/discord-proxy-patch.umd.js";function u(){let e;return{name:"discord-proxy-patch",enforce:"pre",configResolved(o){e=o.command},transform(o,i){if(i.includes("/node_modules/@discord/embedded-app-sdk")||i.includes("/deps/@discord_embedded-app-sdk.js"))return o.replace(/function patchUrlMappings\s*\(/,"function originalPatchUrlMappings(")+`
`+`
				  globalThis['@robojs/patch'] = { mappings: [] }
          function patchUrlMappings(...args) {
						if (args.length > 0) {
							const prefixes = args[0].map(arg => arg.prefix);
							globalThis['@robojs/patch'].mappings.push(prefixes);
						}

            // Call the original function
            return originalPatchUrlMappings.apply(this, args);
          }
        `},transformIndexHtml(o){const i=e==="build"?p:d;return o.replace("<head>",`<head>
		<script src="${i}"><\/script>`)},async buildStart(){if(e!=="build")return;const o=await this.load({id:d});o!=null&&o.code?this.emitFile({type:"asset",fileName:p,source:o.code}):console.error("Failed to load patch script:",o)}}}const b={patch:y,Vite:u};function y(){f()?(console.log("@robojs/patch: Applying patch for Discord Proxy"),m(),g()):console.log("@robojs/patch: Not in Discord Activity, skipping patch")}b.patch()});
